package com.xzl.xep.pojo;

import javax.persistence.Entity;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

import org.hibernate.validator.constraints.NotBlank;

@Entity
@Table(name="dp_product")
public class Product extends IdEntity {

	@NotNull
	private Long companyId;
	
	private String companyName;
	
	@NotBlank
	private String code;
	
	@NotBlank
	private String name;
	
	@NotNull
	private Double price;
	
	@NotNull
	private Integer status;
	
	@NotNull
	private Integer saleCountsTotal;
	
	@NotNull
	private Double saleAmountsTotal;
	
	@NotNull
	private Integer saleCountsLast;
	
	@NotNull
	private Double saleAmountsLast;

	public Long getCompanyId() {
		return companyId;
	}

	public void setCompanyId(Long companyId) {
		this.companyId = companyId;
	}

	public String getCompanyName() {
		return companyName;
	}

	public void setCompanyName(String companyName) {
		this.companyName = companyName;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Double getPrice() {
		return price;
	}

	public void setPrice(Double price) {
		this.price = price;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public Integer getSaleCountsTotal() {
		return saleCountsTotal;
	}

	public void setSaleCountsTotal(Integer saleCountsTotal) {
		this.saleCountsTotal = saleCountsTotal;
	}

	public Double getSaleAmountsTotal() {
		return saleAmountsTotal;
	}

	public void setSaleAmountsTotal(Double saleAmountsTotal) {
		this.saleAmountsTotal = saleAmountsTotal;
	}

	public Integer getSaleCountsLast() {
		return saleCountsLast;
	}

	public void setSaleCountsLast(Integer saleCountsLast) {
		this.saleCountsLast = saleCountsLast;
	}

	public Double getSaleAmountsLast() {
		return saleAmountsLast;
	}

	public void setSaleAmountsLast(Double saleAmountsLast) {
		this.saleAmountsLast = saleAmountsLast;
	}

	public void sale(Integer count) {
		// TODO Auto-generated method stub
		this.saleCountsTotal += count;
		this.saleAmountsTotal += this.price * count;
		
	}
	
	
	
}
